package com.project.dao.impl;

import com.project.bean.CountryBean;
import com.project.dao.ICountryDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class CountryDaoImpl extends BaseDao implements ICountryDao {
    @Override
    public List<CountryBean> findAll() {
        List<CountryBean> list = new ArrayList<>();
        this.setConnection();
        try {
            ps = con.prepareStatement("select * from t_contry");
            rs = ps.executeQuery();
            while (rs.next()) {
                CountryBean countyBean = new CountryBean();
                countyBean.setId(rs.getInt("pk_contryId"));
                countyBean.setName(rs.getString("t_name"));
                list.add(countyBean);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            this.closeConnection();
        }
        return list;
    }
}
